//
//  MapViewController.m
//  RCA24
//
//  Created by Bogdan Boca on 2/16/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "MapViewController.h"

@implementation MapViewController

@synthesize mapView;
@synthesize backButton;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [mapView setDelegate:self];
    
    mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 45, 320, 415)];
    mapView.mapType = MKMapTypeStandard;
    
    CLLocationCoordinate2D coord = {46.77, 23.60};
    MKCoordinateSpan span = {3, 3};
    MKCoordinateRegion region = {coord, span};

    
    MapAnnotation* annotation = [[MapAnnotation alloc] initWithCoordinate:coord];
    [mapView addAnnotation:annotation];
    [annotation release];
    
    
    [mapView setRegion:region];
    [self.view addSubview:mapView];

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void) dealloc
{
    [super dealloc];
    
    [mapView release];
    
    [backButton release];
}

- (IBAction)buttonPressed:(id)sender
{
    if(sender == backButton)
    {
        [self.navigationController popViewControllerAnimated:true]; 
    }
}

@end
